import { Injectable, EventEmitter, enableProdMode } from '@angular/core';
import { Subject } from 'rxjs/Rx';

@Injectable()
export class DataService {
  private dataSource = new Subject<any>();
  private trendSource = new Subject<any>();

  // To broadcast tree selection changes from ztree
  data$ = this.dataSource.asObservable().share();
  trend$ = this.trendSource.asObservable().share();

  /**
   * string for events, object for data!
   */
  updateData(type: any) {
    this.dataSource.next(type);
  }

  updateTrendData(data: any) {
    this.trendSource.next(data);
  }
}
